var __wl_util__;
var __vue__;

function initWLUtil(store, vue) {
    __wl_util__ = store;
    __vue__ = vue;

}
function WLStore() {
    return __wl_util__;
}



function WLDispatch(type, data) {
    __wl_util__.dispatch(type, data);
}
function WLCommit(type, data) {
    __wl_util__.commit(type, data);
}

function WLMessage(txt, type) {
    __vue__.Message.call(null, { message: txt, type: type });
}

function WLSuccess(txt) {
    __vue__.Message.success(txt);
}
function cd(msg, data = "") {
    console.log(msg + '', data)
}

function isArray(arr) {
    return Object.prototype.toString.call(arr) == '[object Array]';
}

function isString(string) {
    return Object.prototype.toString.call(string) == '[object String]';
}

function isNoEmptyObject(obj) {
    for (var i in obj) {
        if (obj.hasOwnProperty(i)) {
            return true;
        }
    }
    return false;
}

function isNoEmpty(value) {
    if (value === "" || value === " ") {
        return false
    }
    if (value === null) {
        return false
    }
    if (value === undefined) {
        return false
    }
    if (isArray(value) && value.length == 0) {
        return false
    }
    return true
}
function getKeyByValue(tpyeId, value) {
    var localStringData = localStorage.getItem("localUserData");
    var _serverData = JSON.parse(localStringData);
    var arrayData = _serverData.data.optonInfo[tpyeId];
    var realKey;
    for (let i = 0; i < arrayData.length; i++) {
        if (arrayData[i]["opValue"] === value) {
            realKey = arrayData[i]["opKey"];
        }
    }
    return realKey;
}

function getValueByKey(tpyeId, key) {
    var localStringData = localStorage.getItem("localUserData");
    var _serverData = JSON.parse(localStringData);
    var arrayData = _serverData.data.optonInfo[tpyeId];
    var realValue = null
    if (isNoEmpty(arrayData)) {
        for (let i = 0; i < arrayData.length; i++) {
            if (arrayData[i]["opKey"] === key + '') {
                realValue = arrayData[i]["opValue"];
            }
        }
    }
    return realValue
}


function enumList(code, key) {
    var localStringData = localStorage.getItem("localUserData");

    var _serverData = JSON.parse(localStringData);

    var arrayData = _serverData.data.classInfo;
    var optonArr = _serverData.data.optonInfo;

    for (let i in arrayData) {
        if (code == i) {
            for (let j in arrayData[i]) {
                if (key == j) {
                    let index = arrayData[i][j];
                    return optonArr[index];
                }
            }
        }
    }
}

function enumVal(code, key, val) {
    var arr = enumList(code, key);

    for (let k = 0; k < arr.length; k++) {
        if (arr[k].opKey == val) {
            return arr[k]
        }
    }
}

function getUserInfo() {
    var localStringData = localStorage.getItem("localUserData");
    var _serverData = JSON.parse(localStringData);
    var userInfo;
    if (_serverData) {
        userInfo = _serverData.data.userInfo;
    }
    return userInfo
}

function timestampToTime(timestamp) {
    //时间戳为10位需*1000，时间戳为13位的话不需乘1000
    var date = new Date(timestamp);
    var Y, M, D;
    Y = date.getFullYear() + "-";
    M =
        (date.getMonth() + 1 < 10
            ? "0" + (date.getMonth() + 1)
            : date.getMonth() + 1) + "-";
    D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();

    // h = date.getHours() + ":";
    // m = date.getMinutes() + ":";
    // s = date.getSeconds();
    return Y + M + D;
}

function timestampToAddOneTime(timestamp) {
    //时间戳为10位需*1000，时间戳为13位的话不需乘1000
    var date = new Date(timestamp);
    var Y, M, D;
    Y = date.getFullYear() + "-";
    M =
        (date.getMonth() + 1 < 10
            ? "0" + (date.getMonth() + 1)
            : date.getMonth() + 1) + "-";
    D = date.getDate() + 1 < 10 ? "0" + (date.getDate() + 1) : date.getDate() + 1;

    // h = date.getHours() + ":";
    // m = date.getMinutes() + ":";
    // s = date.getSeconds();
    return Y + M + D;
}

function restart() {
    if (window.javaExecute) {
        window.javaExecute.restart()
    }
}